package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.SysRole;
import com.itheima.youdianda.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("sys_role")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;

    @GetMapping("list") //GET 角色列表-分页
    public R list(@RequestParam String page,
                  @RequestParam String limit,
                  @RequestParam String name){
       return sysRoleService.listSysRole(page,limit,name);
    }

    @PostMapping("update") //POST 角色修改
    public R update(@RequestBody SysRole sysRole){
       sysRoleService.updateSysRole(sysRole);
       return R.success(null);
    }

    @GetMapping("rowInfo")  //GET 角色详情
    public R rowInfo(String id){
       return sysRoleService.rowInfo(id);
    }

    @PostMapping("add")  //todo:POST 角色添加,id没处理
    public R add(@RequestBody Map<String, java.lang.Object> map){
        sysRoleService.add(map);
        return R.success(null);
    }

    @GetMapping("del")  //GET 角色删除
    public R delete(String id){
       sysRoleService.delete(id);
       return R.success(null);
    }











}
